<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>InFact: src/infact/factory.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">InFact
   
   </div>
   <div id="projectbrief">Interpreter and factory for easily creating C++ objects at run-time</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">src/infact/factory.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="factory_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright 2014, Google Inc.</span>
<a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span>
<a name="l00003"></a>00003 <span class="comment">//</span>
<a name="l00004"></a>00004 <span class="comment">// Redistribution and use in source and binary forms, with or without</span>
<a name="l00005"></a>00005 <span class="comment">// modification, are permitted provided that the following conditions are</span>
<a name="l00006"></a>00006 <span class="comment">// met:</span>
<a name="l00007"></a>00007 <span class="comment">//</span>
<a name="l00008"></a>00008 <span class="comment">//   * Redistributions of source code must retain the above copyright</span>
<a name="l00009"></a>00009 <span class="comment">//     notice, this list of conditions and the following disclaimer.</span>
<a name="l00010"></a>00010 <span class="comment">//   * Redistributions in binary form must reproduce the above</span>
<a name="l00011"></a>00011 <span class="comment">//     copyright notice, this list of conditions and the following disclaimer</span>
<a name="l00012"></a>00012 <span class="comment">//     in the documentation and/or other materials provided with the</span>
<a name="l00013"></a>00013 <span class="comment">//     distribution.</span>
<a name="l00014"></a>00014 <span class="comment">//   * Neither the name of Google Inc. nor the names of its</span>
<a name="l00015"></a>00015 <span class="comment">//     contributors may be used to endorse or promote products derived from</span>
<a name="l00016"></a>00016 <span class="comment">//     this software without specific prior written permission.</span>
<a name="l00017"></a>00017 <span class="comment">//</span>
<a name="l00018"></a>00018 <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span>
<a name="l00019"></a>00019 <span class="comment">// &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span>
<a name="l00020"></a>00020 <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span>
<a name="l00021"></a>00021 <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span>
<a name="l00022"></a>00022 <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span>
<a name="l00023"></a>00023 <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span>
<a name="l00024"></a>00024 <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span>
<a name="l00025"></a>00025 <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span>
<a name="l00026"></a>00026 <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span>
<a name="l00027"></a>00027 <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span>
<a name="l00028"></a>00028 <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00029"></a>00029 <span class="comment">// -----------------------------------------------------------------------------</span>
<a name="l00030"></a>00030 <span class="comment">//</span>
<a name="l00031"></a>00031 <span class="comment">//</span>
<a name="l00035"></a>00035 <span class="comment"></span>
<a name="l00036"></a>00036 <span class="preprocessor">#ifndef INFACT_FACTORY_H_</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#define INFACT_FACTORY_H_</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;sstream&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;memory&gt;</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include &lt;unordered_map&gt;</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include &lt;unordered_set&gt;</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include &lt;stdexcept&gt;</span>
<a name="l00046"></a>00046 
<a name="l00047"></a>00047 <span class="preprocessor">#include &quot;<a class="code" href="environment_8h.html" title="Provides an interface for an Environment, which contains a map from variables of a specific type (pri...">environment.h</a>&quot;</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include &quot;<a class="code" href="error_8h.html" title="Provides an error handling function that optionally throws an exception.">error.h</a>&quot;</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include &quot;<a class="code" href="stream-tokenizer_8h.html" title="Provides the StreamTokenizer  class.">stream-tokenizer.h</a>&quot;</span>
<a name="l00050"></a>00050 
<a name="l00062"></a><a class="code" href="factory_8h.html#ac51fe909a3ebeed75d2995096306c7cb">00062</a> <span class="preprocessor">#define INFACT_ADD_PARAM(param) initializers.Add(#param, &amp;_ ## param)</span>
<a name="l00063"></a>00063 <span class="preprocessor"></span>
<a name="l00075"></a><a class="code" href="factory_8h.html#a6398dd334cb48923f39b26dbcf2497b9">00075</a> <span class="preprocessor">#define INFACT_ADD_PARAM_(param) initializers.Add(#param, &amp;param ## _)</span>
<a name="l00076"></a>00076 <span class="preprocessor"></span>
<a name="l00079"></a><a class="code" href="factory_8h.html#a3d20c0cb4655d546c046123a8b70806f">00079</a> <span class="preprocessor">#define INFACT_ADD_REQUIRED_PARAM(param) \</span>
<a name="l00080"></a>00080 <span class="preprocessor">  initializers.Add(#param, &amp;_ ## param, true)</span>
<a name="l00081"></a>00081 <span class="preprocessor"></span>
<a name="l00083"></a><a class="code" href="factory_8h.html#ad079b320f02a7a940b66c2e10162e321">00083</a> <span class="preprocessor">#define INFACT_ADD_REQUIRED_PARAM_(param) \</span>
<a name="l00084"></a>00084 <span class="preprocessor">  initializers.Add(#param, &amp;param ## _, true)</span>
<a name="l00085"></a>00085 <span class="preprocessor"></span>
<a name="l00093"></a><a class="code" href="factory_8h.html#ae1e1f80dddb9011fa00e128c3eccc7bd">00093</a> <span class="preprocessor">#define INFACT_ADD_TEMPORARY(type, var) \</span>
<a name="l00094"></a>00094 <span class="preprocessor">  initializers.Add(#var, static_cast&lt;type *&gt;(nullptr))</span>
<a name="l00095"></a>00095 <span class="preprocessor"></span>
<a name="l00124"></a><a class="code" href="factory_8h.html#a26a18d2d4565d41ecc64cb5d96862132">00124</a> <span class="preprocessor">#define INFACT_ADD_REQUIRED_TEMPORARY(type, var) \</span>
<a name="l00125"></a>00125 <span class="preprocessor">  initializers.Add(#var, static_cast&lt;type *&gt;(nullptr), true)</span>
<a name="l00126"></a>00126 <span class="preprocessor"></span>
<a name="l00127"></a>00127 <span class="keyword">namespace </span>infact {
<a name="l00128"></a>00128 
<a name="l00129"></a>00129 <span class="keyword">using</span> std::cerr;
<a name="l00130"></a>00130 <span class="keyword">using</span> std::endl;
<a name="l00131"></a>00131 <span class="keyword">using</span> std::ostream;
<a name="l00132"></a>00132 <span class="keyword">using</span> std::ostringstream;
<a name="l00133"></a>00133 <span class="keyword">using</span> std::shared_ptr;
<a name="l00134"></a>00134 <span class="keyword">using</span> std::unordered_map;
<a name="l00135"></a>00135 <span class="keyword">using</span> std::unordered_set;
<a name="l00136"></a>00136 <span class="keyword">using</span> std::vector;
<a name="l00137"></a>00137 
<a name="l00153"></a>00153 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00154"></a><a class="code" href="classinfact_1_1_type_name.html">00154</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a> {
<a name="l00155"></a>00155  <span class="keyword">public</span>:
<a name="l00156"></a><a class="code" href="classinfact_1_1_type_name.html#a1b098d38421124bfdf82922ae5a7fb22">00156</a>   <span class="keywordtype">string</span> <a class="code" href="classinfact_1_1_type_name.html#a1b098d38421124bfdf82922ae5a7fb22">ToString</a>() {
<a name="l00157"></a>00157     <span class="keywordflow">return</span> <a class="code" href="classinfact_1_1_factory.html" title="Factory for dynamically created instance of the specified type.">Factory&lt;T&gt;</a>().BaseName();
<a name="l00158"></a>00158   }
<a name="l00159"></a>00159 };
<a name="l00160"></a>00160 
<a name="l00163"></a>00163 <span class="keyword">template</span> &lt;&gt;
<a name="l00164"></a><a class="code" href="classinfact_1_1_type_name_3_01bool_01_4.html">00164</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a>&lt;bool&gt; {
<a name="l00165"></a>00165  <span class="keyword">public</span>:
<a name="l00166"></a><a class="code" href="classinfact_1_1_type_name_3_01bool_01_4.html#a7f15410787540053706a059d00b84132">00166</a>   <span class="keywordtype">string</span> <a class="code" href="classinfact_1_1_type_name_3_01bool_01_4.html#a7f15410787540053706a059d00b84132">ToString</a>() {
<a name="l00167"></a>00167     <span class="keywordflow">return</span> <span class="stringliteral">&quot;bool&quot;</span>;
<a name="l00168"></a>00168   }
<a name="l00169"></a>00169 };
<a name="l00170"></a>00170 
<a name="l00173"></a>00173 <span class="keyword">template</span> &lt;&gt;
<a name="l00174"></a><a class="code" href="classinfact_1_1_type_name_3_01int_01_4.html">00174</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a>&lt;int&gt; {
<a name="l00175"></a>00175  <span class="keyword">public</span>:
<a name="l00176"></a><a class="code" href="classinfact_1_1_type_name_3_01int_01_4.html#aef47722fac156159e102ef73d51dde9f">00176</a>   <span class="keywordtype">string</span> <a class="code" href="classinfact_1_1_type_name_3_01int_01_4.html#aef47722fac156159e102ef73d51dde9f">ToString</a>() {
<a name="l00177"></a>00177     <span class="keywordflow">return</span> <span class="stringliteral">&quot;int&quot;</span>;
<a name="l00178"></a>00178   }
<a name="l00179"></a>00179 };
<a name="l00180"></a>00180 
<a name="l00183"></a>00183 <span class="keyword">template</span> &lt;&gt;
<a name="l00184"></a><a class="code" href="classinfact_1_1_type_name_3_01double_01_4.html">00184</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a>&lt;double&gt; {
<a name="l00185"></a>00185  <span class="keyword">public</span>:
<a name="l00186"></a><a class="code" href="classinfact_1_1_type_name_3_01double_01_4.html#a5880a4a1563c84367d8421539871e45d">00186</a>   <span class="keywordtype">string</span> <a class="code" href="classinfact_1_1_type_name_3_01double_01_4.html#a5880a4a1563c84367d8421539871e45d">ToString</a>() {
<a name="l00187"></a>00187     <span class="keywordflow">return</span> <span class="stringliteral">&quot;double&quot;</span>;
<a name="l00188"></a>00188   }
<a name="l00189"></a>00189 };
<a name="l00190"></a>00190 
<a name="l00193"></a>00193 <span class="keyword">template</span> &lt;&gt;
<a name="l00194"></a><a class="code" href="classinfact_1_1_type_name_3_01string_01_4.html">00194</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a>&lt;string&gt; {
<a name="l00195"></a>00195  <span class="keyword">public</span>:
<a name="l00196"></a><a class="code" href="classinfact_1_1_type_name_3_01string_01_4.html#aea9be77686e31edf1a235f67e8b81818">00196</a>   <span class="keywordtype">string</span> <a class="code" href="classinfact_1_1_type_name_3_01string_01_4.html#aea9be77686e31edf1a235f67e8b81818">ToString</a>() {
<a name="l00197"></a>00197     <span class="keywordflow">return</span> <span class="stringliteral">&quot;string&quot;</span>;
<a name="l00198"></a>00198   }
<a name="l00199"></a>00199 };
<a name="l00200"></a>00200 
<a name="l00205"></a>00205 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00206"></a><a class="code" href="classinfact_1_1_type_name_3_01shared__ptr_3_01_t_01_4_01_4.html">00206</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a>&lt;shared_ptr&lt;T&gt; &gt; {
<a name="l00207"></a>00207  <span class="keyword">public</span>:
<a name="l00208"></a><a class="code" href="classinfact_1_1_type_name_3_01shared__ptr_3_01_t_01_4_01_4.html#ad766f2c32695c1b799f4e71a1fb0cc61">00208</a>   <span class="keywordtype">string</span> <a class="code" href="classinfact_1_1_type_name_3_01shared__ptr_3_01_t_01_4_01_4.html#ad766f2c32695c1b799f4e71a1fb0cc61">ToString</a>() {
<a name="l00209"></a>00209     <span class="keywordflow">return</span> <a class="code" href="classinfact_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName&lt;T&gt;</a>().<a class="code" href="classinfact_1_1_type_name.html#a1b098d38421124bfdf82922ae5a7fb22">ToString</a>();
<a name="l00210"></a>00210   }
<a name="l00211"></a>00211 };
<a name="l00212"></a>00212 
<a name="l00220"></a>00220 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00221"></a><a class="code" href="classinfact_1_1_type_name_3_01vector_3_01_t_01_4_01_4.html">00221</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a>&lt;vector&lt;T&gt; &gt; {
<a name="l00222"></a>00222  <span class="keyword">public</span>:
<a name="l00223"></a><a class="code" href="classinfact_1_1_type_name_3_01vector_3_01_t_01_4_01_4.html#a2bcb8115bdf3d01e097935d7152f5baa">00223</a>   <span class="keywordtype">string</span> <a class="code" href="classinfact_1_1_type_name_3_01vector_3_01_t_01_4_01_4.html#a2bcb8115bdf3d01e097935d7152f5baa">ToString</a>() {
<a name="l00224"></a>00224     <span class="keywordflow">return</span> <a class="code" href="classinfact_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName&lt;T&gt;</a>().<a class="code" href="classinfact_1_1_type_name.html#a1b098d38421124bfdf82922ae5a7fb22">ToString</a>() + <span class="stringliteral">&quot;[]&quot;</span>;
<a name="l00225"></a>00225   }
<a name="l00226"></a>00226 };
<a name="l00227"></a>00227 
<a name="l00232"></a><a class="code" href="classinfact_1_1_member_initializer.html">00232</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_member_initializer.html" title="An interface for data member initializers of members of a Factory-constructible object.">MemberInitializer</a> {
<a name="l00233"></a>00233  <span class="keyword">public</span>:
<a name="l00237"></a>00237   <span class="comment">//                  appear in spec strings parsed by the</span>
<a name="l00241"></a><a class="code" href="classinfact_1_1_member_initializer.html#a009d3a4d4f8bb978dcdd49a95884055f">00241</a> <span class="comment"></span>  <a class="code" href="classinfact_1_1_member_initializer.html#a009d3a4d4f8bb978dcdd49a95884055f" title="Initializes this base class.">MemberInitializer</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;name, <span class="keywordtype">bool</span> required) :
<a name="l00242"></a>00242       <a class="code" href="classinfact_1_1_member_initializer.html#aba7bfd5ae08968fcf60e55f6cfa2e9fb" title="The name of this member.">name_</a>(name), <a class="code" href="classinfact_1_1_member_initializer.html#af646d58820304e5b4ff25f72c7be7eb6" title="The number of times this member initializer&rsquo;s Init method has been invoked.">initialized_</a>(0), <a class="code" href="classinfact_1_1_member_initializer.html#a68a94a1f24011a691a331580267408d1" title="Whether this member is required to be initialized.">required_</a>(required) { }
<a name="l00243"></a>00243 
<a name="l00245"></a><a class="code" href="classinfact_1_1_member_initializer.html#a55b1f4a0465b453ea829f777a19cba5c">00245</a>   <span class="keyword">virtual</span> <a class="code" href="classinfact_1_1_member_initializer.html#a55b1f4a0465b453ea829f777a19cba5c" title="Destroys this instance.">~MemberInitializer</a>() { }
<a name="l00246"></a>00246 
<a name="l00253"></a><a class="code" href="classinfact_1_1_member_initializer.html#a0e4554037bfda0b286043639e251dca4">00253</a>   <span class="keyword">virtual</span> <span class="keywordtype">string</span> <a class="code" href="classinfact_1_1_member_initializer.html#a0e4554037bfda0b286043639e251dca4" title="Returns the name of the member initialized by this instance, as it should appear in a spec string par...">Name</a>() { <span class="keywordflow">return</span> <a class="code" href="classinfact_1_1_member_initializer.html#aba7bfd5ae08968fcf60e55f6cfa2e9fb" title="The name of this member.">name_</a>; }
<a name="l00254"></a>00254 
<a name="l00262"></a>00262   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classinfact_1_1_member_initializer.html#a4c12e33f71273d982c073dffdb08ff01" title="Initializes this instance based on the following tokens obtained from the specified StreamTokenizer...">Init</a>(<a class="code" href="classinfact_1_1_stream_tokenizer.html" title="A simple class for tokenizing a stream of tokens for the formally specified language used to construc...">StreamTokenizer</a> &amp;st, <a class="code" href="classinfact_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env) = 0;
<a name="l00263"></a>00263 
<a name="l00266"></a><a class="code" href="classinfact_1_1_member_initializer.html#a6bc9747bc681d4eef7ce2f155a4e509d">00266</a>   <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classinfact_1_1_member_initializer.html#a6bc9747bc681d4eef7ce2f155a4e509d" title="Returns the number of times this member initializer&rsquo;s Init method has been invoked.">Initialized</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classinfact_1_1_member_initializer.html#af646d58820304e5b4ff25f72c7be7eb6" title="The number of times this member initializer&rsquo;s Init method has been invoked.">initialized_</a>; }
<a name="l00267"></a>00267 
<a name="l00269"></a><a class="code" href="classinfact_1_1_member_initializer.html#a51229eee1ad22cacb7665f5abc72fe32">00269</a>   <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classinfact_1_1_member_initializer.html#a51229eee1ad22cacb7665f5abc72fe32" title="Whether this member is required to be initialized in a spec string.">Required</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classinfact_1_1_member_initializer.html#a68a94a1f24011a691a331580267408d1" title="Whether this member is required to be initialized.">required_</a>; }
<a name="l00270"></a>00270 
<a name="l00271"></a>00271  <span class="keyword">protected</span>:
<a name="l00273"></a><a class="code" href="classinfact_1_1_member_initializer.html#aba7bfd5ae08968fcf60e55f6cfa2e9fb">00273</a>   <span class="keywordtype">string</span> <a class="code" href="classinfact_1_1_member_initializer.html#aba7bfd5ae08968fcf60e55f6cfa2e9fb" title="The name of this member.">name_</a>;
<a name="l00276"></a><a class="code" href="classinfact_1_1_member_initializer.html#af646d58820304e5b4ff25f72c7be7eb6">00276</a>   <span class="keywordtype">int</span> <a class="code" href="classinfact_1_1_member_initializer.html#af646d58820304e5b4ff25f72c7be7eb6" title="The number of times this member initializer&rsquo;s Init method has been invoked.">initialized_</a>;
<a name="l00278"></a><a class="code" href="classinfact_1_1_member_initializer.html#a68a94a1f24011a691a331580267408d1">00278</a>   <span class="keywordtype">bool</span> <a class="code" href="classinfact_1_1_member_initializer.html#a68a94a1f24011a691a331580267408d1" title="Whether this member is required to be initialized.">required_</a>;
<a name="l00279"></a>00279 };
<a name="l00280"></a>00280 
<a name="l00289"></a>00289 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00290"></a><a class="code" href="classinfact_1_1_typed_member_initializer.html">00290</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_typed_member_initializer.html" title="A concrete, typed implementation of the MemberInitializer base class.">TypedMemberInitializer</a> : <span class="keyword">public</span> <a class="code" href="classinfact_1_1_member_initializer.html" title="An interface for data member initializers of members of a Factory-constructible object.">MemberInitializer</a> {
<a name="l00291"></a>00291  <span class="keyword">public</span>:
<a name="l00296"></a>00296   <span class="comment">//                  appear in spec strings parsed by the</span>
<a name="l00306"></a><a class="code" href="classinfact_1_1_typed_member_initializer.html#a4736328841b5ab169acac7b2049142c4">00306</a> <span class="comment"></span>  <a class="code" href="classinfact_1_1_typed_member_initializer.html#a4736328841b5ab169acac7b2049142c4" title="A concrete implementation of the MemberInitializer base class, holding a pointer to a typed member th...">TypedMemberInitializer</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;name, T *member, <span class="keywordtype">bool</span> required = <span class="keyword">false</span>) :
<a name="l00307"></a>00307       <a class="code" href="classinfact_1_1_member_initializer.html" title="An interface for data member initializers of members of a Factory-constructible object.">MemberInitializer</a>(name, required), <a class="code" href="classinfact_1_1_typed_member_initializer.html#ab786ff72080c4be52d8fac9de46850bb">member_</a>(member) { }
<a name="l00308"></a><a class="code" href="classinfact_1_1_typed_member_initializer.html#a883e4ce6b7191c74ac42a46449b54369">00308</a>   <span class="keyword">virtual</span> <a class="code" href="classinfact_1_1_typed_member_initializer.html#a883e4ce6b7191c74ac42a46449b54369">~TypedMemberInitializer</a>() { }
<a name="l00309"></a><a class="code" href="classinfact_1_1_typed_member_initializer.html#aa3e873d6c512b552c15f9a6833802c3b">00309</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classinfact_1_1_typed_member_initializer.html#aa3e873d6c512b552c15f9a6833802c3b" title="Initializes this instance based on the following tokens obtained from the specified StreamTokenizer...">Init</a>(<a class="code" href="classinfact_1_1_stream_tokenizer.html" title="A simple class for tokenizing a stream of tokens for the formally specified language used to construc...">StreamTokenizer</a> &amp;st, <a class="code" href="classinfact_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env) {
<a name="l00310"></a>00310     env-&gt;<a class="code" href="classinfact_1_1_environment.html#aab3e8026af3825eb80cd54e89c9379bd" title="Sets the specified variable to the value obtained from the following tokens available from the specif...">ReadAndSet</a>(<a class="code" href="classinfact_1_1_member_initializer.html#a0e4554037bfda0b286043639e251dca4" title="Returns the name of the member initialized by this instance, as it should appear in a spec string par...">Name</a>(), st, <a class="code" href="classinfact_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName&lt;T&gt;</a>().ToString());
<a name="l00311"></a>00311     <span class="keywordflow">if</span> (<a class="code" href="classinfact_1_1_typed_member_initializer.html#ab786ff72080c4be52d8fac9de46850bb">member_</a> != <span class="keyword">nullptr</span>) {
<a name="l00312"></a>00312       <a class="code" href="classinfact_1_1_var_map_base.html" title="A base class for a mapping from variables of a specific type to their values.">VarMapBase</a> *var_map = env-&gt;<a class="code" href="classinfact_1_1_environment.html#a96f39caaea04c08e5da848f74e26927a" title="Retrieves the VarMap instance for the specified variable.">GetVarMap</a>(<a class="code" href="classinfact_1_1_member_initializer.html#a0e4554037bfda0b286043639e251dca4" title="Returns the name of the member initialized by this instance, as it should appear in a spec string par...">Name</a>());
<a name="l00313"></a>00313       <a class="code" href="classinfact_1_1_var_map.html" title="A container to hold the mapping between named variables of a specific type and their values...">VarMap&lt;T&gt;</a> *typed_var_map = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classinfact_1_1_var_map.html" title="A container to hold the mapping between named variables of a specific type and their values...">VarMap&lt;T&gt;</a> *<span class="keyword">&gt;</span>(var_map);
<a name="l00314"></a>00314       <span class="keywordflow">if</span> (typed_var_map != <span class="keyword">nullptr</span>) {
<a name="l00315"></a>00315         <span class="keywordtype">bool</span> success = typed_var_map-&gt;<a class="code" href="classinfact_1_1_var_map_impl.html#a7995e8a182a980899b4a0c90eee0d110" title="Assigns the value of the specified variable to the object pointed to by the value parameter...">Get</a>(<a class="code" href="classinfact_1_1_member_initializer.html#a0e4554037bfda0b286043639e251dca4" title="Returns the name of the member initialized by this instance, as it should appear in a spec string par...">Name</a>(), <a class="code" href="classinfact_1_1_typed_member_initializer.html#ab786ff72080c4be52d8fac9de46850bb">member_</a>);
<a name="l00316"></a>00316         <span class="keywordflow">if</span> (success) {
<a name="l00317"></a>00317           ++<a class="code" href="classinfact_1_1_member_initializer.html#af646d58820304e5b4ff25f72c7be7eb6" title="The number of times this member initializer&rsquo;s Init method has been invoked.">initialized_</a>;
<a name="l00318"></a>00318         }
<a name="l00319"></a>00319       }
<a name="l00320"></a>00320     } <span class="keywordflow">else</span> {
<a name="l00321"></a>00321       <span class="comment">// When the goal is simply to modify the environment, we say that this</span>
<a name="l00322"></a>00322       <span class="comment">// &quot;non-member&quot; has been successfully initialized when we&#39;ve modified</span>
<a name="l00323"></a>00323       <span class="comment">// the environment.</span>
<a name="l00324"></a>00324       ++<a class="code" href="classinfact_1_1_member_initializer.html#af646d58820304e5b4ff25f72c7be7eb6" title="The number of times this member initializer&rsquo;s Init method has been invoked.">initialized_</a>;
<a name="l00325"></a>00325     }
<a name="l00326"></a>00326   }
<a name="l00327"></a>00327  <span class="keyword">protected</span>:
<a name="l00328"></a><a class="code" href="classinfact_1_1_typed_member_initializer.html#ab786ff72080c4be52d8fac9de46850bb">00328</a>   T *<a class="code" href="classinfact_1_1_typed_member_initializer.html#ab786ff72080c4be52d8fac9de46850bb">member_</a>;
<a name="l00329"></a>00329 };
<a name="l00330"></a>00330 
<a name="l00337"></a><a class="code" href="classinfact_1_1_initializers.html">00337</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_initializers.html" title="A container for all the member initializers for a particular Factory-constructible instance...">Initializers</a> {
<a name="l00338"></a>00338  <span class="keyword">public</span>:
<a name="l00341"></a>00341   <span class="keyword">typedef</span> unordered_map&lt;string, MemberInitializer *&gt;::const_iterator
<a name="l00342"></a><a class="code" href="classinfact_1_1_initializers.html#a4fc9267fb231848052fe96843c1758d1">00342</a>       <a class="code" href="classinfact_1_1_initializers.html#a4fc9267fb231848052fe96843c1758d1" title="Forward the const_iterator typedef of the internal data structure, to make code compact and readable...">const_iterator</a>;
<a name="l00345"></a><a class="code" href="classinfact_1_1_initializers.html#a873d5a9d6458351331c6135d62017071">00345</a>   <span class="keyword">typedef</span> unordered_map&lt;string, MemberInitializer *&gt;::iterator <a class="code" href="classinfact_1_1_initializers.html#a873d5a9d6458351331c6135d62017071" title="Forward the iterator typedef of the internal data structure, to make code compact and readable...">iterator</a>;
<a name="l00346"></a>00346 
<a name="l00348"></a><a class="code" href="classinfact_1_1_initializers.html#a60c906676bec66dc2162991bb2756a38">00348</a>   <a class="code" href="classinfact_1_1_initializers.html#a60c906676bec66dc2162991bb2756a38" title="Constructs a new instance.">Initializers</a>() { }
<a name="l00350"></a><a class="code" href="classinfact_1_1_initializers.html#ae5017d2b8c6784ba2f3d32e595c97a4b">00350</a>   <span class="keyword">virtual</span> <a class="code" href="classinfact_1_1_initializers.html#ae5017d2b8c6784ba2f3d32e595c97a4b" title="Destroys this instance.">~Initializers</a>() {
<a name="l00351"></a>00351     <span class="keywordflow">for</span> (<a class="code" href="classinfact_1_1_initializers.html#a873d5a9d6458351331c6135d62017071" title="Forward the iterator typedef of the internal data structure, to make code compact and readable...">iterator</a> init_it = initializers_.begin();
<a name="l00352"></a>00352          init_it != initializers_.end();
<a name="l00353"></a>00353          ++init_it) {
<a name="l00354"></a>00354       <span class="keyword">delete</span> init_it-&gt;second;
<a name="l00355"></a>00355     }
<a name="l00356"></a>00356   }
<a name="l00357"></a>00357 
<a name="l00375"></a>00375   <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;
<a name="l00376"></a><a class="code" href="classinfact_1_1_initializers.html#a33d96794d73289dd072351a8fa269728">00376</a>   <span class="keywordtype">void</span> <a class="code" href="classinfact_1_1_initializers.html#a33d96794d73289dd072351a8fa269728" title="This method is the raison d&#39;etre of this class: a method to make it easy to add all supported types o...">Add</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;name, T *member, <span class="keywordtype">bool</span> required = <span class="keyword">false</span>) {
<a name="l00377"></a>00377     <span class="keywordflow">if</span> (initializers_.find(name) != initializers_.end()) {
<a name="l00378"></a>00378       ostringstream err_ss;
<a name="l00379"></a>00379       err_ss &lt;&lt; <span class="stringliteral">&quot;Initializers::Add: error: two members have the same name: &quot;</span>
<a name="l00380"></a>00380              &lt;&lt; name;
<a name="l00381"></a>00381       <a class="code" href="namespaceinfact.html#a746fb382cf3fd6cf656f40669d90372c" title="Reports an error encountered during parsing and/or construction of an object.">Error</a>(err_ss.str());
<a name="l00382"></a>00382     }
<a name="l00383"></a>00383     initializers_[name] = <span class="keyword">new</span> <a class="code" href="classinfact_1_1_typed_member_initializer.html" title="A concrete, typed implementation of the MemberInitializer base class.">TypedMemberInitializer&lt;T&gt;</a>(name, member, required);
<a name="l00384"></a>00384   }
<a name="l00385"></a>00385 
<a name="l00389"></a><a class="code" href="classinfact_1_1_initializers.html#a6f55934b05f5ef066889d4bd3207dd4e">00389</a>   <a class="code" href="classinfact_1_1_initializers.html#a4fc9267fb231848052fe96843c1758d1" title="Forward the const_iterator typedef of the internal data structure, to make code compact and readable...">const_iterator</a> <a class="code" href="classinfact_1_1_initializers.html#a6f55934b05f5ef066889d4bd3207dd4e" title="Returns a const iterator pointing to the beginning of the map from member names to pointers to TypedM...">begin</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> initializers_.begin(); }
<a name="l00394"></a><a class="code" href="classinfact_1_1_initializers.html#a8d307841fdb94d157ef0ab1f6c26d399">00394</a>   <a class="code" href="classinfact_1_1_initializers.html#a4fc9267fb231848052fe96843c1758d1" title="Forward the const_iterator typedef of the internal data structure, to make code compact and readable...">const_iterator</a> <a class="code" href="classinfact_1_1_initializers.html#a8d307841fdb94d157ef0ab1f6c26d399" title="Returns a const iterator pointing to the end of the map from member names to pointers to TypedMemberI...">end</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> initializers_.end(); }
<a name="l00395"></a>00395 
<a name="l00400"></a><a class="code" href="classinfact_1_1_initializers.html#a979e2b920494feaeb79c3e810bf347ea">00400</a>   <a class="code" href="classinfact_1_1_initializers.html#a873d5a9d6458351331c6135d62017071" title="Forward the iterator typedef of the internal data structure, to make code compact and readable...">iterator</a> <a class="code" href="classinfact_1_1_initializers.html#a979e2b920494feaeb79c3e810bf347ea" title="Returns an iterator pointing to the beginning of the map from member names to pointers to TypedMember...">begin</a>() { <span class="keywordflow">return</span> initializers_.begin(); }
<a name="l00404"></a><a class="code" href="classinfact_1_1_initializers.html#a569211fc0cd0bb306b6f5c5773cbccab">00404</a>   <a class="code" href="classinfact_1_1_initializers.html#a873d5a9d6458351331c6135d62017071" title="Forward the iterator typedef of the internal data structure, to make code compact and readable...">iterator</a> <a class="code" href="classinfact_1_1_initializers.html#a569211fc0cd0bb306b6f5c5773cbccab" title="Returns an iterator pointing to the end of the map from member names to pointers to TypedMemberInitia...">end</a>() { <span class="keywordflow">return</span> initializers_.end(); }
<a name="l00405"></a>00405 
<a name="l00411"></a><a class="code" href="classinfact_1_1_initializers.html#a0769a511be9253244af09b761e958fb0">00411</a>   <a class="code" href="classinfact_1_1_initializers.html#a4fc9267fb231848052fe96843c1758d1" title="Forward the const_iterator typedef of the internal data structure, to make code compact and readable...">const_iterator</a> <a class="code" href="classinfact_1_1_initializers.html#a0769a511be9253244af09b761e958fb0" title="Returns a const_iterator pointing to the MemberInitializer associated with the specified name...">find</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;name)<span class="keyword"> const </span>{
<a name="l00412"></a>00412     <span class="keywordflow">return</span> initializers_.find(name);
<a name="l00413"></a>00413   }
<a name="l00419"></a><a class="code" href="classinfact_1_1_initializers.html#ad219edc2cf780658667bc462e2b70d0e">00419</a>   <a class="code" href="classinfact_1_1_initializers.html#a873d5a9d6458351331c6135d62017071" title="Forward the iterator typedef of the internal data structure, to make code compact and readable...">iterator</a> <a class="code" href="classinfact_1_1_initializers.html#ad219edc2cf780658667bc462e2b70d0e" title="Returns an iterator pointing to the MemberInitializer associated with the specified name...">find</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;name) {
<a name="l00420"></a>00420     <span class="keywordflow">return</span> initializers_.find(name);
<a name="l00421"></a>00421   }
<a name="l00422"></a>00422  <span class="keyword">private</span>:
<a name="l00423"></a>00423   unordered_map&lt;string, MemberInitializer *&gt; initializers_;
<a name="l00424"></a>00424 };
<a name="l00425"></a>00425 
<a name="l00428"></a><a class="code" href="classinfact_1_1_factory_base.html">00428</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_factory_base.html" title="An interface for all Factory instances, specifying a few pure virtual methods.">FactoryBase</a> {
<a name="l00429"></a>00429  <span class="keyword">public</span>:
<a name="l00430"></a><a class="code" href="classinfact_1_1_factory_base.html#a656bc3024e1f6072138126307fc07510">00430</a>   <span class="keyword">virtual</span> <a class="code" href="classinfact_1_1_factory_base.html#a656bc3024e1f6072138126307fc07510">~FactoryBase</a>() { }
<a name="l00436"></a>00436   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classinfact_1_1_factory_base.html#a0bfd1d5815782ffff1fac35c36567fee" title="Clears the (possibly static) data of this factory.">Clear</a>() = 0;
<a name="l00438"></a>00438   <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">string</span> <a class="code" href="classinfact_1_1_factory_base.html#ab11fc85e901a402e3db2ea88a0fd76bb" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() <span class="keyword">const</span> = 0;
<a name="l00445"></a>00445   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classinfact_1_1_factory_base.html#ad801507cc88948faf540cdfee4e02319" title="Collects the names of types registered with this factory.">CollectRegistered</a>(unordered_set&lt;string&gt; &amp;registered) <span class="keyword">const</span> = 0;
<a name="l00446"></a>00446 
<a name="l00447"></a>00447   <span class="keyword">virtual</span> <a class="code" href="classinfact_1_1_var_map_base.html" title="A base class for a mapping from variables of a specific type to their values.">VarMapBase</a> *<a class="code" href="classinfact_1_1_factory_base.html#a1cc61a662485882019f4fecfe7b6b54e">CreateVarMap</a>(<a class="code" href="classinfact_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env) <span class="keyword">const</span> = 0;
<a name="l00448"></a>00448 
<a name="l00449"></a>00449   <span class="keyword">virtual</span> <a class="code" href="classinfact_1_1_var_map_base.html" title="A base class for a mapping from variables of a specific type to their values.">VarMapBase</a> *<a class="code" href="classinfact_1_1_factory_base.html#a612b59d8e802ab667304264a8d3dca72">CreateVectorVarMap</a>(<a class="code" href="classinfact_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env) <span class="keyword">const</span> = 0;
<a name="l00450"></a>00450 };
<a name="l00451"></a>00451 
<a name="l00453"></a><a class="code" href="classinfact_1_1_factory_container.html">00453</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_factory_container.html" title="A class to hold all Factory instances that have been created.">FactoryContainer</a> {
<a name="l00454"></a>00454  <span class="keyword">public</span>:
<a name="l00455"></a><a class="code" href="classinfact_1_1_factory_container.html#a3456b9a71e1e50f7dc01b9f9a9e3cf10">00455</a>   <span class="keyword">typedef</span> vector&lt;FactoryBase *&gt;::iterator <a class="code" href="classinfact_1_1_factory_container.html#a3456b9a71e1e50f7dc01b9f9a9e3cf10">iterator</a>;
<a name="l00456"></a>00456 
<a name="l00460"></a><a class="code" href="classinfact_1_1_factory_container.html#a557a5f3c79c1bd105bec2855918a6f43">00460</a>   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classinfact_1_1_factory_container.html#a557a5f3c79c1bd105bec2855918a6f43" title="Adds the specified factory to this container of factories.">Add</a>(<a class="code" href="classinfact_1_1_factory_base.html" title="An interface for all Factory instances, specifying a few pure virtual methods.">FactoryBase</a> *factory) {
<a name="l00461"></a>00461     <span class="keywordflow">if</span> (!initialized_) {
<a name="l00462"></a>00462       factories_ = <span class="keyword">new</span> vector&lt;FactoryBase *&gt;();
<a name="l00463"></a>00463       initialized_ = 1;
<a name="l00464"></a>00464     }
<a name="l00465"></a>00465     factories_-&gt;push_back(factory);
<a name="l00466"></a>00466   }
<a name="l00468"></a><a class="code" href="classinfact_1_1_factory_container.html#aba97b9aac442e88ae96016d255191881">00468</a>   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classinfact_1_1_factory_container.html#aba97b9aac442e88ae96016d255191881" title="Clears this container of factories.">Clear</a>() {
<a name="l00469"></a>00469     <span class="keywordflow">if</span> (initialized_) {
<a name="l00470"></a>00470       <span class="keywordflow">for</span> (vector&lt;FactoryBase *&gt;::iterator it = factories_-&gt;begin();
<a name="l00471"></a>00471            it != factories_-&gt;end();
<a name="l00472"></a>00472            ++it) {
<a name="l00473"></a>00473         (*it)-&gt;Clear();
<a name="l00474"></a>00474         <span class="keyword">delete</span> *it;
<a name="l00475"></a>00475       }
<a name="l00476"></a>00476       <span class="keyword">delete</span> factories_;
<a name="l00477"></a>00477     }
<a name="l00478"></a>00478   }
<a name="l00479"></a>00479 
<a name="l00480"></a>00480   <span class="comment">// Provide two methods to iterate over the FactoryBase instances</span>
<a name="l00481"></a>00481   <span class="comment">// held by this FactoryContainer.</span>
<a name="l00482"></a><a class="code" href="classinfact_1_1_factory_container.html#ad0cf611e0cbe39559cf16a452bcfd48d">00482</a>   <span class="keyword">static</span> <a class="code" href="classinfact_1_1_factory_container.html#a3456b9a71e1e50f7dc01b9f9a9e3cf10">iterator</a> <a class="code" href="classinfact_1_1_factory_container.html#ad0cf611e0cbe39559cf16a452bcfd48d">begin</a>() {
<a name="l00483"></a>00483     <span class="keywordflow">if</span> (factories_ == <span class="keyword">nullptr</span>) {
<a name="l00484"></a>00484       cerr &lt;&lt; <span class="stringliteral">&quot;FactoryContainer::begin: error: no FactoryBase instances!&quot;</span>
<a name="l00485"></a>00485            &lt;&lt; endl;
<a name="l00486"></a>00486     }
<a name="l00487"></a>00487     <span class="keywordflow">return</span> factories_-&gt;begin();
<a name="l00488"></a>00488   }
<a name="l00489"></a><a class="code" href="classinfact_1_1_factory_container.html#a23a97c788ceaec0d10adfeb5b26f40c0">00489</a>   <span class="keyword">static</span> <a class="code" href="classinfact_1_1_factory_container.html#a3456b9a71e1e50f7dc01b9f9a9e3cf10">iterator</a> <a class="code" href="classinfact_1_1_factory_container.html#a23a97c788ceaec0d10adfeb5b26f40c0">end</a>() {
<a name="l00490"></a>00490     <span class="keywordflow">if</span> (factories_ == <span class="keyword">nullptr</span>) {
<a name="l00491"></a>00491       cerr &lt;&lt; <span class="stringliteral">&quot;FactoryContainer::begin: error: no FactoryBase instances!&quot;</span>
<a name="l00492"></a>00492            &lt;&lt; endl;
<a name="l00493"></a>00493     }
<a name="l00494"></a>00494     <span class="keywordflow">return</span> factories_-&gt;end();
<a name="l00495"></a>00495   }
<a name="l00496"></a>00496 
<a name="l00500"></a><a class="code" href="classinfact_1_1_factory_container.html#a418b82017d6262c1a91e3cc7b55bccca">00500</a>   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classinfact_1_1_factory_container.html#a418b82017d6262c1a91e3cc7b55bccca" title="Prints the base typenames for all factories along with a list of all concrete subtypes those factorie...">Print</a>(ostream &amp;os) {
<a name="l00501"></a>00501     <span class="keywordflow">if</span> (!initialized_) {
<a name="l00502"></a>00502       <span class="keywordflow">return</span>;
<a name="l00503"></a>00503     }
<a name="l00504"></a>00504     cerr &lt;&lt; <span class="stringliteral">&quot;Number of factories: &quot;</span> &lt;&lt; factories_-&gt;size() &lt;&lt; <span class="stringliteral">&quot;.&quot;</span> &lt;&lt; endl;
<a name="l00505"></a>00505     <span class="keywordflow">for</span> (vector&lt;FactoryBase *&gt;::iterator factory_it = factories_-&gt;begin();
<a name="l00506"></a>00506          factory_it != factories_-&gt;end();
<a name="l00507"></a>00507          ++factory_it) {
<a name="l00508"></a>00508       unordered_set&lt;string&gt; registered;
<a name="l00509"></a>00509       (*factory_it)-&gt;CollectRegistered(registered);
<a name="l00510"></a>00510       os &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; (*factory_it)-&gt;BaseName() &lt;&lt; <span class="stringliteral">&quot;&gt; can construct:\n&quot;</span>;
<a name="l00511"></a>00511       <span class="keywordflow">for</span> (unordered_set&lt;string&gt;::const_iterator it = registered.begin();
<a name="l00512"></a>00512            it != registered.end();
<a name="l00513"></a>00513            ++it) {
<a name="l00514"></a>00514         os &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span> &lt;&lt; *it &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;
<a name="l00515"></a>00515       }
<a name="l00516"></a>00516     }
<a name="l00517"></a>00517     os.flush();
<a name="l00518"></a>00518   }
<a name="l00519"></a>00519  <span class="keyword">private</span>:
<a name="l00520"></a>00520   <span class="keyword">static</span> <span class="keywordtype">int</span> initialized_;
<a name="l00521"></a>00521   <span class="keyword">static</span> vector&lt;FactoryBase *&gt; *factories_;
<a name="l00522"></a>00522 };
<a name="l00523"></a>00523 
<a name="l00529"></a>00529 <span class="comment">// \tparam T the abstract type that this &lt;tt&gt;Constructor&lt;/tt&gt; constructs</span>
<a name="l00530"></a>00530 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00531"></a><a class="code" href="classinfact_1_1_constructor.html">00531</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_constructor.html" title="An interface with a single virtual method that constructs a concrete instance of the abstract type T...">Constructor</a> {
<a name="l00532"></a>00532  <span class="keyword">public</span>:
<a name="l00533"></a><a class="code" href="classinfact_1_1_constructor.html#a07924077e7cc6bab5601e87df3447e5c">00533</a>   <span class="keyword">virtual</span> <a class="code" href="classinfact_1_1_constructor.html#a07924077e7cc6bab5601e87df3447e5c">~Constructor</a>() { }
<a name="l00534"></a>00534   <span class="keyword">virtual</span> T *<a class="code" href="classinfact_1_1_constructor.html#afd33bc032e5c21796c9c9f5a0d05a66e">NewInstance</a>() <span class="keyword">const</span> = 0;
<a name="l00535"></a>00535 };
<a name="l00536"></a>00536 
<a name="l00549"></a><a class="code" href="classinfact_1_1_factory_constructible.html">00549</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_factory_constructible.html" title="An interface simply to make it easier to implement Factory-constructible types by implementing both r...">FactoryConstructible</a> {
<a name="l00550"></a>00550  <span class="keyword">public</span>:
<a name="l00552"></a><a class="code" href="classinfact_1_1_factory_constructible.html#a71837c2002fe8f555036eed482b105e3">00552</a>   <span class="keyword">virtual</span> <a class="code" href="classinfact_1_1_factory_constructible.html#a71837c2002fe8f555036eed482b105e3" title="Destroys this instance.">~FactoryConstructible</a>() { }
<a name="l00553"></a>00553 
<a name="l00570"></a><a class="code" href="classinfact_1_1_factory_constructible.html#a1c186ded6db298b7a84e5767e87c740f">00570</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classinfact_1_1_factory_constructible.html#a1c186ded6db298b7a84e5767e87c740f" title="Registers data members of this class for initialization when an instance is constructed via the Facto...">RegisterInitializers</a>(<a class="code" href="classinfact_1_1_initializers.html" title="A container for all the member initializers for a particular Factory-constructible instance...">Initializers</a> &amp;initializers) { }
<a name="l00571"></a>00571 
<a name="l00583"></a><a class="code" href="classinfact_1_1_factory_constructible.html#abbcefaf8b2137f888ef133807cefe083">00583</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classinfact_1_1_factory_constructible.html#abbcefaf8b2137f888ef133807cefe083" title="Does any additional initialization after an instance of this class has been constructed, crucially giving access to the Environment  that was in use and modified during construction by the Factory::CreateOrDie  method.">PostInit</a>(<span class="keyword">const</span> <a class="code" href="classinfact_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env, <span class="keyword">const</span> <span class="keywordtype">string</span> &amp;init_str) { }
<a name="l00584"></a>00584 };
<a name="l00585"></a>00585 
<a name="l00592"></a>00592 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00593"></a><a class="code" href="classinfact_1_1_factory.html">00593</a> <span class="keyword">class </span><a class="code" href="classinfact_1_1_factory.html" title="Factory for dynamically created instance of the specified type.">Factory</a> : <span class="keyword">public</span> <a class="code" href="classinfact_1_1_factory_base.html" title="An interface for all Factory instances, specifying a few pure virtual methods.">FactoryBase</a> {
<a name="l00594"></a>00594  <span class="keyword">public</span>:
<a name="l00596"></a><a class="code" href="classinfact_1_1_factory.html#aeee238dea345546be513d9e871a3b8af">00596</a>   <a class="code" href="classinfact_1_1_factory.html#aeee238dea345546be513d9e871a3b8af" title="Constructs a new factory.">Factory</a>() { }
<a name="l00597"></a>00597 
<a name="l00603"></a><a class="code" href="classinfact_1_1_factory.html#a0da8e64d55dfe9c99d37feec9ccbacb2">00603</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classinfact_1_1_factory.html#a0da8e64d55dfe9c99d37feec9ccbacb2" title="Clears this factory of all (possibly static) data.">Clear</a>() {
<a name="l00604"></a>00604     <a class="code" href="classinfact_1_1_factory.html#a9438277a67d200ca87cc08ec2c46cbde" title="Clears all static data associated with this class.">ClearStatic</a>();
<a name="l00605"></a>00605   }
<a name="l00606"></a>00606 
<a name="l00762"></a><a class="code" href="classinfact_1_1_factory.html#a8b2771ba4fac39a71cb1d0156ddba7b6">00762</a>   shared_ptr&lt;T&gt; <a class="code" href="classinfact_1_1_factory.html#a8b2771ba4fac39a71cb1d0156ddba7b6" title="Dynamically creates an object, whose type and initialization are contained in a specification string...">CreateOrDie</a>(<a class="code" href="classinfact_1_1_stream_tokenizer.html" title="A simple class for tokenizing a stream of tokens for the formally specified language used to construc...">StreamTokenizer</a> &amp;st, <a class="code" href="classinfact_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env = <span class="keyword">nullptr</span>) {
<a name="l00763"></a>00763     shared_ptr&lt;Environment&gt; env_ptr(env == <span class="keyword">nullptr</span> ?
<a name="l00764"></a>00764                                     <a class="code" href="classinfact_1_1_environment.html#ac155016aa1651ef2303906fa24976771" title="A static factory method to create a new, empty Environment instance.">Environment::CreateEmpty</a>() : env-&gt;<a class="code" href="classinfact_1_1_environment.html#ade64259636e7933ff9f02d46bda298e6" title="Returns a copy of this environment.">Copy</a>());
<a name="l00765"></a>00765     <span class="keywordtype">size_t</span> start = st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#acbafcc5e7f6a0b3e4cd8166c4a53f4a8" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>();
<a name="l00766"></a>00766     <a class="code" href="classinfact_1_1_stream_tokenizer.html#ac6e5b0b274a66a2a504ac4fd425c57b3" title="The set of types of tokens read by this stream tokenizer.">StreamTokenizer::TokenType</a> token_type = st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a50a622f50ef6aa800a9c7c15b96bb6cb" title="Returns the type of the next token, or EOF_TYPE if there is no next token.">PeekTokenType</a>();
<a name="l00767"></a>00767     <span class="keywordflow">if</span> (token_type == <a class="code" href="classinfact_1_1_stream_tokenizer.html#ac6e5b0b274a66a2a504ac4fd425c57b3a1c9eaa574c618f243aa51efe253d3118">StreamTokenizer::RESERVED_WORD</a> &amp;&amp;
<a name="l00768"></a>00768         (st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() == <span class="stringliteral">&quot;nullptr&quot;</span> || st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() == <span class="stringliteral">&quot;NULL&quot;</span>)) {
<a name="l00769"></a>00769       <span class="comment">// Consume the nullptr.</span>
<a name="l00770"></a>00770       st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#ac6827f00a3da760e23241e890becee0c" title="Returns the next token in the token stream.">Next</a>();
<a name="l00771"></a>00771       <span class="keywordflow">return</span> shared_ptr&lt;T&gt;();
<a name="l00772"></a>00772     }
<a name="l00773"></a>00773     <span class="keywordflow">if</span> (token_type != <a class="code" href="classinfact_1_1_stream_tokenizer.html#ac6e5b0b274a66a2a504ac4fd425c57b3a61f308d29c6dd30996fcb120b6344e41">StreamTokenizer::IDENTIFIER</a>) {
<a name="l00774"></a>00774       ostringstream err_ss;
<a name="l00775"></a>00775       err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00776"></a>00776              &lt;&lt; <span class="stringliteral">&quot;error: expected type specifier token but found &quot;</span>
<a name="l00777"></a>00777              &lt;&lt; <a class="code" href="classinfact_1_1_stream_tokenizer.html#acd4baaa4ccb442e4398550e2f8c76419" title="Returns a string type name for the specified TokenType constant.">StreamTokenizer::TypeName</a>(token_type);
<a name="l00778"></a>00778       <a class="code" href="namespaceinfact.html#a746fb382cf3fd6cf656f40669d90372c" title="Reports an error encountered during parsing and/or construction of an object.">Error</a>(err_ss.str());
<a name="l00779"></a>00779     }
<a name="l00780"></a>00780 
<a name="l00781"></a>00781     <span class="comment">// Read the concrete type of object to be created.</span>
<a name="l00782"></a>00782     <span class="keywordtype">string</span> type = st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#ac6827f00a3da760e23241e890becee0c" title="Returns the next token in the token stream.">Next</a>();
<a name="l00783"></a>00783 
<a name="l00784"></a>00784     <span class="comment">// Read the open parenthesis token.</span>
<a name="l00785"></a>00785     <span class="keywordflow">if</span> (st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;(&quot;</span>) {
<a name="l00786"></a>00786       ostringstream err_ss;
<a name="l00787"></a>00787       err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00788"></a>00788              &lt;&lt; <span class="stringliteral">&quot;error: expected &#39;(&#39; at stream position &quot;</span>
<a name="l00789"></a>00789              &lt;&lt; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#acbafcc5e7f6a0b3e4cd8166c4a53f4a8" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>() &lt;&lt; <span class="stringliteral">&quot; but found \&quot;&quot;</span> &lt;&lt; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00790"></a>00790       <a class="code" href="namespaceinfact.html#a746fb382cf3fd6cf656f40669d90372c" title="Reports an error encountered during parsing and/or construction of an object.">Error</a>(err_ss.str());
<a name="l00791"></a>00791     }
<a name="l00792"></a>00792     st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#ac6827f00a3da760e23241e890becee0c" title="Returns the next token in the token stream.">Next</a>();
<a name="l00793"></a>00793 
<a name="l00794"></a>00794     <span class="comment">// Attempt to create an instance of type.</span>
<a name="l00795"></a>00795     <span class="keyword">typename</span> unordered_map&lt;string, const Constructor&lt;T&gt; *&gt;::iterator cons_it =
<a name="l00796"></a>00796         cons_table_-&gt;find(type);
<a name="l00797"></a>00797     <span class="keywordflow">if</span> (cons_it == cons_table_-&gt;end()) {
<a name="l00798"></a>00798       ostringstream err_ss;
<a name="l00799"></a>00799       err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00800"></a>00800              &lt;&lt; <span class="stringliteral">&quot;error: unknown type: \&quot;&quot;</span> &lt;&lt; type &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00801"></a>00801       <a class="code" href="namespaceinfact.html#a746fb382cf3fd6cf656f40669d90372c" title="Reports an error encountered during parsing and/or construction of an object.">Error</a>(err_ss.str());
<a name="l00802"></a>00802     }
<a name="l00803"></a>00803     shared_ptr&lt;T&gt; instance(cons_it-&gt;second-&gt;NewInstance());
<a name="l00804"></a>00804 
<a name="l00805"></a>00805     <span class="comment">// Ask new instance to set up member initializers.</span>
<a name="l00806"></a>00806     <a class="code" href="classinfact_1_1_initializers.html" title="A container for all the member initializers for a particular Factory-constructible instance...">Initializers</a> initializers;
<a name="l00807"></a>00807     instance-&gt;RegisterInitializers(initializers);
<a name="l00808"></a>00808 
<a name="l00809"></a>00809     <span class="comment">// Parse initializer list.</span>
<a name="l00810"></a>00810     <span class="keywordflow">while</span> (st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;)&quot;</span>) {
<a name="l00811"></a>00811       token_type = st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a50a622f50ef6aa800a9c7c15b96bb6cb" title="Returns the type of the next token, or EOF_TYPE if there is no next token.">PeekTokenType</a>();
<a name="l00812"></a>00812       <span class="keywordflow">if</span> (token_type != <a class="code" href="classinfact_1_1_stream_tokenizer.html#ac6e5b0b274a66a2a504ac4fd425c57b3a61f308d29c6dd30996fcb120b6344e41">StreamTokenizer::IDENTIFIER</a>) {
<a name="l00813"></a>00813         ostringstream err_ss;
<a name="l00814"></a>00814         err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00815"></a>00815                &lt;&lt; <span class="stringliteral">&quot;error: expected token of type IDENTIFIER at &quot;</span>
<a name="l00816"></a>00816                &lt;&lt; <span class="stringliteral">&quot;stream position &quot;</span> &lt;&lt; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#acbafcc5e7f6a0b3e4cd8166c4a53f4a8" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>() &lt;&lt; <span class="stringliteral">&quot; but found &quot;</span>
<a name="l00817"></a>00817                &lt;&lt; <a class="code" href="classinfact_1_1_stream_tokenizer.html#acd4baaa4ccb442e4398550e2f8c76419" title="Returns a string type name for the specified TokenType constant.">StreamTokenizer::TypeName</a>(token_type) &lt;&lt; <span class="stringliteral">&quot;: \&quot;&quot;</span>
<a name="l00818"></a>00818                &lt;&lt; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00819"></a>00819         <a class="code" href="namespaceinfact.html#a746fb382cf3fd6cf656f40669d90372c" title="Reports an error encountered during parsing and/or construction of an object.">Error</a>(err_ss.str());
<a name="l00820"></a>00820       }
<a name="l00821"></a>00821       <span class="keywordtype">size_t</span> member_name_start = st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#acbafcc5e7f6a0b3e4cd8166c4a53f4a8" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>();
<a name="l00822"></a>00822       <span class="keywordtype">string</span> member_name = st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#ac6827f00a3da760e23241e890becee0c" title="Returns the next token in the token stream.">Next</a>();
<a name="l00823"></a>00823       <span class="keyword">typename</span> <a class="code" href="classinfact_1_1_initializers.html#a873d5a9d6458351331c6135d62017071" title="Forward the iterator typedef of the internal data structure, to make code compact and readable...">Initializers::iterator</a> init_it = initializers.find(member_name);
<a name="l00824"></a>00824       <span class="keywordflow">if</span> (init_it == initializers.end()) {
<a name="l00825"></a>00825         ostringstream err_ss;
<a name="l00826"></a>00826         err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00827"></a>00827                &lt;&lt; <span class="stringliteral">&quot;error: unknown member name \&quot;&quot;</span> &lt;&lt; member_name
<a name="l00828"></a>00828                &lt;&lt; <span class="stringliteral">&quot;\&quot; in initializer list for type &quot;</span> &lt;&lt; type &lt;&lt; <span class="stringliteral">&quot; at stream &quot;</span>
<a name="l00829"></a>00829                &lt;&lt; <span class="stringliteral">&quot;position &quot;</span> &lt;&lt; member_name_start;
<a name="l00830"></a>00830         <a class="code" href="namespaceinfact.html#a746fb382cf3fd6cf656f40669d90372c" title="Reports an error encountered during parsing and/or construction of an object.">Error</a>(err_ss.str());
<a name="l00831"></a>00831       }
<a name="l00832"></a>00832       <a class="code" href="classinfact_1_1_member_initializer.html" title="An interface for data member initializers of members of a Factory-constructible object.">MemberInitializer</a> *member_initializer = init_it-&gt;second;
<a name="l00833"></a>00833 
<a name="l00834"></a>00834       <span class="comment">// Read open parenthesis.</span>
<a name="l00835"></a>00835       <span class="keywordflow">if</span> (st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;(&quot;</span>) {
<a name="l00836"></a>00836         ostringstream err_ss;
<a name="l00837"></a>00837         err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00838"></a>00838                &lt;&lt; <span class="stringliteral">&quot;error: expected &#39;(&#39; at stream position &quot;</span>
<a name="l00839"></a>00839                &lt;&lt; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#acbafcc5e7f6a0b3e4cd8166c4a53f4a8" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>() &lt;&lt; <span class="stringliteral">&quot; but found \&quot;&quot;</span> &lt;&lt; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00840"></a>00840         <a class="code" href="namespaceinfact.html#a746fb382cf3fd6cf656f40669d90372c" title="Reports an error encountered during parsing and/or construction of an object.">Error</a>(err_ss.str());
<a name="l00841"></a>00841       }
<a name="l00842"></a>00842       st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#ac6827f00a3da760e23241e890becee0c" title="Returns the next token in the token stream.">Next</a>();
<a name="l00843"></a>00843 
<a name="l00844"></a>00844       <span class="comment">// Initialize member based on following token(s).</span>
<a name="l00845"></a>00845       member_initializer-&gt;<a class="code" href="classinfact_1_1_member_initializer.html#a4c12e33f71273d982c073dffdb08ff01" title="Initializes this instance based on the following tokens obtained from the specified StreamTokenizer...">Init</a>(st, env_ptr.get());
<a name="l00846"></a>00846 
<a name="l00847"></a>00847       <span class="comment">// Read close parenthesis for current member initializer.</span>
<a name="l00848"></a>00848       <span class="keywordflow">if</span> (st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;)&quot;</span>) {
<a name="l00849"></a>00849         ostringstream err_ss;
<a name="l00850"></a>00850         err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00851"></a>00851                &lt;&lt; <span class="stringliteral">&quot;error: expected &#39;)&#39; at stream position &quot;</span>
<a name="l00852"></a>00852                &lt;&lt; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#acbafcc5e7f6a0b3e4cd8166c4a53f4a8" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>() &lt;&lt; <span class="stringliteral">&quot; but found \&quot;&quot;</span> &lt;&lt; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00853"></a>00853         <a class="code" href="namespaceinfact.html#a746fb382cf3fd6cf656f40669d90372c" title="Reports an error encountered during parsing and/or construction of an object.">Error</a>(err_ss.str());
<a name="l00854"></a>00854       }
<a name="l00855"></a>00855       st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#ac6827f00a3da760e23241e890becee0c" title="Returns the next token in the token stream.">Next</a>();
<a name="l00856"></a>00856 
<a name="l00857"></a>00857       <span class="comment">// Each member initializer must be followed by a comma or the final</span>
<a name="l00858"></a>00858       <span class="comment">// closing parenthesis.</span>
<a name="l00859"></a>00859       <span class="keywordflow">if</span> (st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;,&quot;</span>  &amp;&amp; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;)&quot;</span>) {
<a name="l00860"></a>00860         ostringstream err_ss;
<a name="l00861"></a>00861         err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00862"></a>00862                &lt;&lt; <span class="stringliteral">&quot;error: expected &#39;,&#39; or &#39;)&#39; at stream position &quot;</span>
<a name="l00863"></a>00863                &lt;&lt; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#acbafcc5e7f6a0b3e4cd8166c4a53f4a8" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>() &lt;&lt; <span class="stringliteral">&quot; but found \&quot;&quot;</span> &lt;&lt; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00864"></a>00864         <a class="code" href="namespaceinfact.html#a746fb382cf3fd6cf656f40669d90372c" title="Reports an error encountered during parsing and/or construction of an object.">Error</a>(err_ss.str());
<a name="l00865"></a>00865       }
<a name="l00866"></a>00866       <span class="comment">// Read comma, if present.</span>
<a name="l00867"></a>00867       <span class="keywordflow">if</span> (st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() == <span class="stringliteral">&quot;,&quot;</span>) {
<a name="l00868"></a>00868         st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#ac6827f00a3da760e23241e890becee0c" title="Returns the next token in the token stream.">Next</a>();
<a name="l00869"></a>00869       }
<a name="l00870"></a>00870     }
<a name="l00871"></a>00871 
<a name="l00872"></a>00872     <span class="comment">// Read the close parenthesis token for this factory type specification.</span>
<a name="l00873"></a>00873     <span class="keywordflow">if</span> (st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;)&quot;</span>) {
<a name="l00874"></a>00874       ostringstream err_ss;
<a name="l00875"></a>00875       err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00876"></a>00876              &lt;&lt; <span class="stringliteral">&quot;error: expected &#39;)&#39; at stream position &quot;</span>
<a name="l00877"></a>00877              &lt;&lt; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#acbafcc5e7f6a0b3e4cd8166c4a53f4a8" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>() &lt;&lt; <span class="stringliteral">&quot; but found \&quot;&quot;</span> &lt;&lt; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a61ec5de244a34de264e5b18e4809d753" title="Returns the next token that would be returned by the Next method.">Peek</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00878"></a>00878       <a class="code" href="namespaceinfact.html#a746fb382cf3fd6cf656f40669d90372c" title="Reports an error encountered during parsing and/or construction of an object.">Error</a>(err_ss.str());
<a name="l00879"></a>00879     }
<a name="l00880"></a>00880     st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#ac6827f00a3da760e23241e890becee0c" title="Returns the next token in the token stream.">Next</a>();
<a name="l00881"></a>00881 
<a name="l00882"></a>00882     <span class="comment">// Run through all member initializers: if any are required but haven&#39;t</span>
<a name="l00883"></a>00883     <span class="comment">// been invoked, it is an error.</span>
<a name="l00884"></a>00884     <span class="keywordflow">for</span> (<span class="keyword">typename</span> <a class="code" href="classinfact_1_1_initializers.html#a4fc9267fb231848052fe96843c1758d1" title="Forward the const_iterator typedef of the internal data structure, to make code compact and readable...">Initializers::const_iterator</a> init_it = initializers.begin();
<a name="l00885"></a>00885          init_it != initializers.end();
<a name="l00886"></a>00886          ++init_it) {
<a name="l00887"></a>00887       <a class="code" href="classinfact_1_1_member_initializer.html" title="An interface for data member initializers of members of a Factory-constructible object.">MemberInitializer</a> *member_initializer = init_it-&gt;second;
<a name="l00888"></a>00888       <span class="keywordflow">if</span> (member_initializer-&gt;<a class="code" href="classinfact_1_1_member_initializer.html#a51229eee1ad22cacb7665f5abc72fe32" title="Whether this member is required to be initialized in a spec string.">Required</a>() &amp;&amp;
<a name="l00889"></a>00889           member_initializer-&gt;<a class="code" href="classinfact_1_1_member_initializer.html#a6bc9747bc681d4eef7ce2f155a4e509d" title="Returns the number of times this member initializer&rsquo;s Init method has been invoked.">Initialized</a>() == 0) {
<a name="l00890"></a>00890         ostringstream err_ss;
<a name="l00891"></a>00891         err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00892"></a>00892                &lt;&lt; <span class="stringliteral">&quot;error: initialization for member with name \&quot;&quot;</span>
<a name="l00893"></a>00893                &lt;&lt; init_it-&gt;first &lt;&lt; <span class="stringliteral">&quot;\&quot; required but not found (current &quot;</span>
<a name="l00894"></a>00894                &lt;&lt; <span class="stringliteral">&quot;stream position: &quot;</span> &lt;&lt; st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a2f2705cec4fa2f38202e8c3022482fd2" title="Returns the number of bytes read from the underlying byte stream just after scanning the most recent ...">tellg</a>() &lt;&lt; <span class="stringliteral">&quot;)&quot;</span>;
<a name="l00895"></a>00895         <a class="code" href="namespaceinfact.html#a746fb382cf3fd6cf656f40669d90372c" title="Reports an error encountered during parsing and/or construction of an object.">Error</a>(err_ss.str());
<a name="l00896"></a>00896       }
<a name="l00897"></a>00897     }
<a name="l00898"></a>00898 
<a name="l00899"></a>00899     <span class="keywordtype">size_t</span> end = st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a2f2705cec4fa2f38202e8c3022482fd2" title="Returns the number of bytes read from the underlying byte stream just after scanning the most recent ...">tellg</a>();
<a name="l00900"></a>00900     <span class="comment">// Invoke new instance&#39;s Init method.</span>
<a name="l00901"></a>00901     <span class="keywordtype">string</span> stream_str = st.<a class="code" href="classinfact_1_1_stream_tokenizer.html#a3790d1692c84c79af738a9ade303cbd7" title="Returns the entire sequence of characters read so far by this stream tokenizer as a newly constructed...">str</a>();
<a name="l00902"></a>00902     <span class="comment">//cerr &lt;&lt; &quot;Full stream string is: \&quot;&quot; &lt;&lt; stream_str &lt;&lt; &quot;\&quot;&quot; &lt;&lt; endl;</span>
<a name="l00903"></a>00903     <span class="keywordtype">string</span> init_str = stream_str.substr(start, end - start);
<a name="l00904"></a>00904     <span class="comment">//cerr &lt;&lt; &quot;PostInit string is: \&quot;&quot; &lt;&lt; init_str &lt;&lt; &quot;\&quot;&quot; &lt;&lt; endl;</span>
<a name="l00905"></a>00905     instance-&gt;PostInit(env_ptr.get(), init_str);
<a name="l00906"></a>00906 
<a name="l00907"></a>00907     <span class="keywordflow">return</span> instance;
<a name="l00908"></a>00908   }
<a name="l00909"></a>00909 
<a name="l00910"></a><a class="code" href="classinfact_1_1_factory.html#a8442aa06c928e31110fd25b9c80b006d">00910</a>   shared_ptr&lt;T&gt; <a class="code" href="classinfact_1_1_factory.html#a8b2771ba4fac39a71cb1d0156ddba7b6" title="Dynamically creates an object, whose type and initialization are contained in a specification string...">CreateOrDie</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;spec, <span class="keyword">const</span> <span class="keywordtype">string</span> err_msg,
<a name="l00911"></a>00911                             <a class="code" href="classinfact_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env = <span class="keyword">nullptr</span>) {
<a name="l00912"></a>00912     <a class="code" href="classinfact_1_1_stream_tokenizer.html" title="A simple class for tokenizing a stream of tokens for the formally specified language used to construc...">StreamTokenizer</a> st(spec);
<a name="l00913"></a>00913     <span class="keywordflow">return</span> <a class="code" href="classinfact_1_1_factory.html#a8b2771ba4fac39a71cb1d0156ddba7b6" title="Dynamically creates an object, whose type and initialization are contained in a specification string...">CreateOrDie</a>(st, env);
<a name="l00914"></a>00914   }
<a name="l00915"></a>00915 
<a name="l00916"></a>00916 
<a name="l00918"></a><a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee">00918</a>   <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">string</span> <a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> base_name_; }
<a name="l00919"></a>00919 
<a name="l00927"></a><a class="code" href="classinfact_1_1_factory.html#a17872c09395ca9505ed56b165089f749">00927</a>   <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classinfact_1_1_factory.html#a17872c09395ca9505ed56b165089f749" title="Returns whether the specified type has been registered with this factory (where registration happens ...">IsRegistered</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;type) {
<a name="l00928"></a>00928     <span class="keywordflow">return</span> initialized_ &amp;&amp; cons_table_-&gt;find(type) != cons_table_-&gt;end();
<a name="l00929"></a>00929   }
<a name="l00930"></a>00930 
<a name="l00932"></a><a class="code" href="classinfact_1_1_factory.html#a3076c07068d1eab3de4457897b4ba437">00932</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classinfact_1_1_factory.html#a3076c07068d1eab3de4457897b4ba437">CollectRegistered</a>(unordered_set&lt;string&gt; &amp;registered)<span class="keyword"> const </span>{
<a name="l00933"></a>00933     <span class="keywordflow">if</span> (initialized_) {
<a name="l00934"></a>00934       <span class="keywordflow">for</span> (<span class="keyword">typename</span> unordered_map&lt;<span class="keywordtype">string</span>, <span class="keyword">const</span> <a class="code" href="classinfact_1_1_constructor.html" title="An interface with a single virtual method that constructs a concrete instance of the abstract type T...">Constructor&lt;T&gt;</a> *&gt;::iterator it =
<a name="l00935"></a>00935                cons_table_-&gt;begin();
<a name="l00936"></a>00936            it != cons_table_-&gt;end();
<a name="l00937"></a>00937            ++it) {
<a name="l00938"></a>00938         registered.insert(it-&gt;first);
<a name="l00939"></a>00939       }
<a name="l00940"></a>00940     }
<a name="l00941"></a>00941   }
<a name="l00942"></a>00942 
<a name="l00943"></a><a class="code" href="classinfact_1_1_factory.html#a935b3afe182cbaececdaeae2704a6019">00943</a>   <span class="keyword">virtual</span> <a class="code" href="classinfact_1_1_var_map_base.html" title="A base class for a mapping from variables of a specific type to their values.">VarMapBase</a> *<a class="code" href="classinfact_1_1_factory.html#a935b3afe182cbaececdaeae2704a6019">CreateVarMap</a>(<a class="code" href="classinfact_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env)<span class="keyword"> const </span>{
<a name="l00944"></a>00944     <span class="keywordtype">bool</span> is_primitive = <span class="keyword">false</span>;
<a name="l00945"></a>00945     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classinfact_1_1_var_map.html" title="A container to hold the mapping between named variables of a specific type and their values...">VarMap&lt;shared_ptr&lt;T&gt;</a> &gt;(<a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>(), env, is_primitive);
<a name="l00946"></a>00946   }
<a name="l00947"></a>00947 
<a name="l00948"></a><a class="code" href="classinfact_1_1_factory.html#a425fe369a75bbf639c797a1ca5926c63">00948</a>   <span class="keyword">virtual</span> <a class="code" href="classinfact_1_1_var_map_base.html" title="A base class for a mapping from variables of a specific type to their values.">VarMapBase</a> *<a class="code" href="classinfact_1_1_factory.html#a425fe369a75bbf639c797a1ca5926c63">CreateVectorVarMap</a>(<a class="code" href="classinfact_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env)<span class="keyword"> const </span>{
<a name="l00949"></a>00949     <span class="keywordtype">string</span> name = <a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() + <span class="stringliteral">&quot;[]&quot;</span>;
<a name="l00950"></a>00950     <span class="keywordtype">bool</span> is_primitive = <span class="keyword">false</span>;
<a name="l00951"></a>00951     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classinfact_1_1_var_map.html" title="A container to hold the mapping between named variables of a specific type and their values...">VarMap&lt;vector&lt;shared_ptr&lt;T&gt;</a> &gt; &gt;(name, <a class="code" href="classinfact_1_1_factory.html#ad620a617807715cd33c77ad6a68483ee" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>(), env,
<a name="l00952"></a>00952                                                is_primitive);
<a name="l00953"></a>00953   }
<a name="l00954"></a>00954 
<a name="l00960"></a><a class="code" href="classinfact_1_1_factory.html#a39e6a67a0a3f5ba160195bd23826d8aa">00960</a>   <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classinfact_1_1_constructor.html" title="An interface with a single virtual method that constructs a concrete instance of the abstract type T...">Constructor&lt;T&gt;</a> *<a class="code" href="classinfact_1_1_factory.html#a39e6a67a0a3f5ba160195bd23826d8aa" title="The method used by the REGISTER_NAMED macro to ensure that subclasses add themselves to the factory...">Register</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;type,
<a name="l00961"></a>00961                                         <span class="keyword">const</span> <a class="code" href="classinfact_1_1_constructor.html" title="An interface with a single virtual method that constructs a concrete instance of the abstract type T...">Constructor&lt;T&gt;</a> *p) {
<a name="l00962"></a>00962     <span class="keywordflow">if</span> (!initialized_) {
<a name="l00963"></a>00963       cons_table_ = <span class="keyword">new</span> unordered_map&lt;string, const Constructor&lt;T&gt; *&gt;();
<a name="l00964"></a>00964       initialized_ = 1;
<a name="l00965"></a>00965       <a class="code" href="classinfact_1_1_factory_container.html#a557a5f3c79c1bd105bec2855918a6f43" title="Adds the specified factory to this container of factories.">FactoryContainer::Add</a>(<span class="keyword">new</span> <a class="code" href="classinfact_1_1_factory.html" title="Factory for dynamically created instance of the specified type.">Factory&lt;T&gt;</a>());
<a name="l00966"></a>00966     }
<a name="l00967"></a>00967     <span class="keyword">typename</span> unordered_map&lt;string, const Constructor&lt;T&gt; *&gt;::iterator cons_it =
<a name="l00968"></a>00968         cons_table_-&gt;find(type);
<a name="l00969"></a>00969     <span class="keywordflow">if</span> (cons_it == cons_table_-&gt;end()) {
<a name="l00970"></a>00970       (*cons_table_)[type] = p;
<a name="l00971"></a>00971       <span class="keywordflow">return</span> p;
<a name="l00972"></a>00972     } <span class="keywordflow">else</span> {
<a name="l00973"></a>00973       <span class="keyword">delete</span> p;
<a name="l00974"></a>00974       <span class="keywordflow">return</span> cons_it-&gt;second;
<a name="l00975"></a>00975     }
<a name="l00976"></a>00976   }
<a name="l00977"></a>00977 
<a name="l00983"></a><a class="code" href="classinfact_1_1_factory.html#a9438277a67d200ca87cc08ec2c46cbde">00983</a>   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classinfact_1_1_factory.html#a9438277a67d200ca87cc08ec2c46cbde" title="Clears all static data associated with this class.">ClearStatic</a>() {
<a name="l00984"></a>00984     <span class="keywordflow">if</span> (initialized_) {
<a name="l00985"></a>00985       <span class="keywordflow">for</span> (<span class="keyword">typename</span> unordered_map&lt;<span class="keywordtype">string</span>, <span class="keyword">const</span> <a class="code" href="classinfact_1_1_constructor.html" title="An interface with a single virtual method that constructs a concrete instance of the abstract type T...">Constructor&lt;T&gt;</a> *&gt;::iterator it =
<a name="l00986"></a>00986                cons_table_-&gt;begin();
<a name="l00987"></a>00987            it != cons_table_-&gt;end();
<a name="l00988"></a>00988            ++it) {
<a name="l00989"></a>00989         <span class="keyword">delete</span> it-&gt;second;
<a name="l00990"></a>00990       }
<a name="l00991"></a>00991       <span class="keyword">delete</span> cons_table_;
<a name="l00992"></a>00992       initialized_ = 0;
<a name="l00993"></a>00993     }
<a name="l00994"></a>00994   }
<a name="l00995"></a>00995  <span class="keyword">private</span>:
<a name="l00996"></a>00996   <span class="comment">// data members</span>
<a name="l00998"></a>00998 <span class="comment"></span>  <span class="keyword">static</span> <span class="keywordtype">int</span> initialized_;
<a name="l01000"></a>01000   <span class="keyword">static</span> unordered_map&lt;string, const Constructor&lt;T&gt; *&gt; *cons_table_;
<a name="l01001"></a>01001   <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *base_name_;
<a name="l01002"></a>01002 };
<a name="l01003"></a>01003 
<a name="l01004"></a>01004 <span class="comment">// Initialize the templated static data member cons_table_ right here,</span>
<a name="l01005"></a>01005 <span class="comment">// since the compiler will happily remove the duplicate definitions.</span>
<a name="l01006"></a>01006 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l01007"></a>01007 unordered_map&lt;string, const Constructor&lt;T&gt; *&gt; *
<a name="l01008"></a>01008 Factory&lt;T&gt;::cons_table_ = 0;
<a name="l01009"></a>01009 
<a name="l01016"></a><a class="code" href="factory_8h.html#a0440aa6c8d7080a9daa203766dae388d">01016</a> <span class="preprocessor">#define DEFINE_CONS_CLASS(TYPE,NAME,BASE) \</span>
<a name="l01017"></a>01017 <span class="preprocessor">  class NAME ## Constructor : public infact::Constructor&lt;BASE&gt; { \</span>
<a name="l01018"></a>01018 <span class="preprocessor">   public: virtual BASE *NewInstance() const { return new TYPE(); } };</span>
<a name="l01019"></a>01019 <span class="preprocessor"></span>
<a name="l01030"></a><a class="code" href="factory_8h.html#a0b09e4aaef613d7556c07875c7d5a029">01030</a> <span class="preprocessor">#define REGISTER_NAMED(TYPE,NAME,BASE)  \</span>
<a name="l01031"></a>01031 <span class="preprocessor">  DEFINE_CONS_CLASS(TYPE,NAME,BASE) \</span>
<a name="l01032"></a>01032 <span class="preprocessor">  static const infact::Constructor&lt;BASE&gt; *NAME ## _my_protoype = \</span>
<a name="l01033"></a>01033 <span class="preprocessor">      infact::Factory&lt;BASE&gt;::Register(string(#NAME), new NAME ## Constructor());</span>
<a name="l01034"></a>01034 <span class="preprocessor"></span>
<a name="l01037"></a><a class="code" href="factory_8h.html#a01b208854b036ee1381a9289186ff3c2">01037</a> <span class="preprocessor">#define IMPLEMENT_FACTORY(BASE) \</span>
<a name="l01038"></a>01038 <span class="preprocessor">  template&lt;&gt; int infact::Factory&lt;BASE&gt;::initialized_ = 0; \</span>
<a name="l01039"></a>01039 <span class="preprocessor">  template&lt;&gt; const char *infact::Factory&lt;BASE&gt;::base_name_ = #BASE;</span>
<a name="l01040"></a>01040 <span class="preprocessor"></span>
<a name="l01041"></a>01041 }  <span class="comment">// namespace infact</span>
<a name="l01042"></a>01042 
<a name="l01043"></a>01043 <span class="preprocessor">#endif</span>
</pre></div></div><!-- contents -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Wed Apr 23 2014 10:07:52 for InFact by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
